package com.marcjmcd.cop4331;

import java.io.IOException;

import android.media.MediaPlayer;

public class TTS
{
	//Initializes the mediaplayer
	MediaPlayer mp = new MediaPlayer();    
    
    public TTS()
    {    	
    	//Default Constructor
    }

	public void start(String name)
    {   	
		try
		{
			//Tells the media player where the source for the .mp3 is.  Also, replaces spaces with %20 (URL syntax)
	    	mp.setDataSource("http://translate.google.com/translate_tts?" + "q=" + name.replace(" ", "%20")
	                + "&tl=en" + ".mp3");
	 
			mp.prepare();
			mp.start();
		}
		catch(Exception e)
		{
			//Catches network exceptions
			System.out.println("Exception: " + e);
			e.printStackTrace();
		}
    }
}
